fn = os.path.join(ciepy.root, 'output', 'rare_variant_eqtls', 'lead_vars_af.tsv')
lead_vars_af = pd.read_table(fn, index_col=0)
fn = os.path.join(ciepy.root, 'output', 'rare_variant_eqtls', 'unr_lead_vars_af.tsv')
unr_lead_vars_af = pd.read_table(fn, index_col=0)
/frazer01/home/cdeboever/software/anaconda/envs/cie/lib/python2.7/site-packages/matplotlib/gridspec.py:302: UserWarning: This figure includes Axes that are not compatible with tight_layout, so its results might be incorrect.
warnings.warn("This figure includes Axes that are not "
File "<ipython-input-10-0a1363fec7b0>", line 1
3 +
^
SyntaxError: invalid syntax
fig = plt.figure(figsize=(4.48, 4.5), dpi=300)
gs = gridspec.GridSpec(1, 1)
ax = fig.add_subplot(gs[0, 0])
ax.text(0, 0, 'Figure 5',
size=16, va='bottom')
ciepy.clean_axis(ax)
ax.set_xticks([])
ax.set_yticks([])
gs.tight_layout(fig, rect=[0, 0.90, 0.5, 1])
# Rare variants all samples.
gs = gridspec.GridSpec(1, 1)
ax = fig.add_subplot(gs[0, 0])
se = lead_vars_af[lead_vars_af.rare].beta
weights = np.ones_like(se) / float(se.shape[0])
se.hist(ax=ax, bins=np.arange(-3, 3.1, 0.1), label='Rare\n(n={:,})'.format(se.shape[0]),
alpha=0.5, weights=weights, histtype='stepfilled')
se = lead_vars_af[lead_vars_af.rare == False].beta
weights = np.ones_like(se) / float(se.shape[0])
se.hist(ax=ax, bins=np.arange(-3, 3.1, 0.1), label='Common\n(n={:,})'.format(se.shape[0]),
alpha=0.5, weights=weights, histtype='stepfilled')
ax.set_xlim(-3, 3)
ax.set_xlabel('$\\beta$', fontsize=8)
ax.set_ylabel('Fraction of lead variants', fontsize=8)
ax.legend(fontsize=7)
for t in ax.get_xticklabels() + ax.get_yticklabels():
t.set_fontsize(8)
sns.despine(ax=ax)
ax.grid()
gs.tight_layout(fig, rect=[0, 0.45, 0.52, 0.92])
# Rare variants unrelateds.
gs = gridspec.GridSpec(1, 1)
ax = fig.add_subplot(gs[0, 0])
se = unr_lead_vars_af[unr_lead_vars_af.rare].beta
weights = np.ones_like(se) / float(se.shape[0])
se.hist(ax=ax, bins=np.arange(-3, 3.1, 0.1), label='Rare\n(n={:,})'.format(se.shape[0]),
alpha=0.5, weights=weights, histtype='stepfilled')
se = unr_lead_vars_af[unr_lead_vars_af.rare == False].beta
weights = np.ones_like(se) / float(se.shape[0])
se.hist(ax=ax, bins=np.arange(-3, 3.1, 0.1), label='Common\n(n={:,})'.format(se.shape[0]),
alpha=0.5, weights=weights, histtype='stepfilled')
ax.set_xlim(-3, 3)
ax.set_xlabel('$\\beta$', fontsize=8)
ax.set_ylabel('Fraction of lead variants', fontsize=8)
ax.legend(fontsize=7)
for t in ax.get_xticklabels() + ax.get_yticklabels():
t.set_fontsize(8)
sns.despine(ax=ax)
ax.grid()
gs.tight_layout(fig, rect=[0.48, 0.45, 1, 0.92])
# Rare variant allele frequencies.
gs = gridspec.GridSpec(1, 1)
ax = fig.add_subplot(gs[0, 0])
tdf = lead_vars_af[lead_vars_af.rare]
ax.scatter(tdf.AF, tdf.maf, color=cpb.analysis.tableau20[0], alpha=0.5, s=10)
ax.set_yticks(np.arange(0, 0.5, 0.1))
ax.set_xticks(np.arange(0, 0.003, 0.001))
ax.set_xlim(-0.0001, 0.002)
ax.set_ylim(0, 0.42)
for t in ax.get_xticklabels() + ax.get_yticklabels():
t.set_fontsize(8)
ax.set_xlabel('1000 Genomes MAF', fontsize=8)
ax.set_ylabel('CARDiPS 215 MAF', fontsize=8)
sns.despine(ax=ax)
gs.tight_layout(fig, rect=[0, 0, 0.52, 0.5])
# Rare variant allele frequencies.
gs = gridspec.GridSpec(1, 1)
ax = fig.add_subplot(gs[0, 0])
tdf = lead_vars_af[lead_vars_af.rare]
ax.scatter(tdf.maf, tdf.beta, color=cpb.analysis.tableau20[0], alpha=0.5, s=10)
# ax.set_yticks(np.arange(0, 0.5, 0.1))
# ax.set_xticks(np.arange(0, 0.003, 0.001))
ax.set_xlim(-0.05, 0.55)
ax.set_ylim(-2.5, 2.5)
for t in ax.get_xticklabels() + ax.get_yticklabels():
t.set_fontsize(8)
ax.set_xlabel('CARDiPS 215 MAF', fontsize=8)
ax.set_ylabel('$\\beta$', fontsize=8)
ax.hlines(0, -0.05, 0.55, linestyle='--', linewidth=1.25, color='grey')
sns.despine(ax=ax)
gs.tight_layout(fig, rect=[0.48, 0, 1, 0.5])
t = fig.text(0.005, 0.88, 'A', weight='bold',
size=12)
t = fig.text(0.5, 0.88, 'B', weight='bold',
size=12)
t = fig.text(0.005, 0.48, 'C', weight='bold',
size=12)
t = fig.text(0.5, 0.48, 'D', weight='bold',
size=12)
plt.savefig(os.path.join(outdir, 'rare_variants.pdf'));
fs = 10
fig = plt.figure(figsize=(7, 4.5), dpi=300)
# Rare variants all samples.
gs = gridspec.GridSpec(1, 1)
ax = fig.add_subplot(gs[0, 0])
se = lead_vars_af[lead_vars_af.rare].beta
weights = np.ones_like(se) / float(se.shape[0])
se.hist(ax=ax, bins=np.arange(-3, 3.1, 0.1), label='Rare\n(n={:,})'.format(se.shape[0]),
alpha=0.5, weights=weights, histtype='stepfilled')
se = lead_vars_af[lead_vars_af.rare == False].beta
weights = np.ones_like(se) / float(se.shape[0])
se.hist(ax=ax, bins=np.arange(-3, 3.1, 0.1), label='Common\n(n={:,})'.format(se.shape[0]),
alpha=0.5, weights=weights, histtype='stepfilled')
ax.set_xlim(-3, 3)
ax.set_xlabel('Effect size ($\\beta$)', fontsize=fs)
ax.set_ylabel('Fraction of lead variants', fontsize=fs)
ax.legend(fontsize=7)
for t in ax.get_xticklabels() + ax.get_yticklabels():
t.set_fontsize(fs)
sns.despine(ax=ax)
ax.grid()
gs.tight_layout(fig, rect=[0, 0.5, 0.51, 1])
# Rare variants unrelateds.
gs = gridspec.GridSpec(1, 1)
ax = fig.add_subplot(gs[0, 0])
se = unr_lead_vars_af[unr_lead_vars_af.rare].beta
weights = np.ones_like(se) / float(se.shape[0])
se.hist(ax=ax, bins=np.arange(-3, 3.1, 0.1), label='Rare\n(n={:,})'.format(se.shape[0]),
alpha=0.5, weights=weights, histtype='stepfilled')
se = unr_lead_vars_af[unr_lead_vars_af.rare == False].beta
weights = np.ones_like(se) / float(se.shape[0])
se.hist(ax=ax, bins=np.arange(-3, 3.1, 0.1), label='Common\n(n={:,})'.format(se.shape[0]),
alpha=0.5, weights=weights, histtype='stepfilled')
ax.set_xlim(-3, 3)
ax.set_xlabel('Effect size ($\\beta$)', fontsize=fs)
ax.set_ylabel('Fraction of lead variants', fontsize=fs)
ax.legend(fontsize=fs)
for t in ax.get_xticklabels() + ax.get_yticklabels():
t.set_fontsize(fs)
sns.despine(ax=ax)
ax.grid()
gs.tight_layout(fig, rect=[0.49, 0.5, 1, 1])
# Rare variant allele frequencies.
gs = gridspec.GridSpec(1, 1)
ax = fig.add_subplot(gs[0, 0])
tdf = lead_vars_af[lead_vars_af.rare]
ax.scatter(tdf.AF, tdf.maf, color=cpb.analysis.tableau20[0], alpha=0.5, s=20)
ax.set_yticks(np.arange(0, 0.5, 0.1))
ax.set_xticks(np.arange(0, 0.003, 0.001))
ax.set_xlim(-0.0001, 0.002)
ax.set_ylim(0, 0.42)
for t in ax.get_xticklabels() + ax.get_yticklabels():
t.set_fontsize(fs)
ax.set_xlabel('1000 Genomes MAF', fontsize=fs)
ax.set_ylabel('CARDiPS 215 MAF', fontsize=fs)
sns.despine(ax=ax)
gs.tight_layout(fig, rect=[0, 0, 0.52, 0.5])
# Rare variant allele frequencies.
gs = gridspec.GridSpec(1, 1)
ax = fig.add_subplot(gs[0, 0])
tdf = lead_vars_af[lead_vars_af.rare]
ax.scatter(tdf.maf, tdf.beta, color=cpb.analysis.tableau20[0], alpha=0.5, s=20)
# ax.set_yticks(np.arange(0, 0.5, 0.1))
# ax.set_xticks(np.arange(0, 0.003, 0.001))
ax.set_xlim(-0.05, 0.55)
ax.set_ylim(-2.5, 2.5)
for t in ax.get_xticklabels() + ax.get_yticklabels():
t.set_fontsize(fs)
ax.set_xlabel('CARDiPS 215 MAF', fontsize=fs)
ax.set_ylabel('Effect size ($\\beta$)', fontsize=fs)
ax.hlines(0, -0.05, 0.55, linestyle='--', linewidth=1.25, color='grey')
sns.despine(ax=ax)
gs.tight_layout(fig, rect=[0.48, 0, 1, 0.5])
plt.savefig(os.path.join(outdir, 'rare_variants_presentation.pdf'));